package flc.ast.widget.calendar;

import android.annotation.SuppressLint;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.widget.RemoteViews;

import com.blankj.utilcode.util.TimeUtils;

import java.util.Date;

import flc.ast.R;

public class Calendar1Widget extends BaseCalendarWidget {

    public Calendar1Widget(int appWidgetId) {
        super(appWidgetId);
    }

    @Override
    protected void onUpdate(Context context) {
        @SuppressLint("RemoteViewLayout") RemoteViews remoteViews =
                new RemoteViews(context.getPackageName(), R.layout.widget_calendar1);

        String date = TimeUtils.date2String(new Date(), "yyyy.MM.dd");
        String week = TimeUtils.date2String(new Date(), "E");
        remoteViews.setTextViewText(R.id.tvCalendar1Date, date);
        remoteViews.setTextViewText(R.id.tvCalendar1Week, week);

        AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews);
    }
}
